#!/usr/bin/env python2.5
from .log import log_gui
import gtk 
import hildon
import kinetic
import osso
from menu import Menu, MenuItem, RunCallback

if __name__ == "__main__":
  window = hildon.Window()
  window.fullscreen()
  window.connect("destroy", gtk.main_quit)

  fixed = gtk.Fixed()
  window.add(fixed)

  menu = Menu("Test", fixed)
  menu2 = Menu("Submenu", fixed)

  def doit(menu, menuitem):
    menu.Replace(menu2)
    return True

  for i in range(30):
    menu.AddItem(MenuItem("test %d" % i, RunCallback(doit)))

  menu.SetVisible(True)
  fixed.put(menu.widget(), 100, 0)

  # --

  def doit(menu, menuitem):
    log_gui("You clicked on", menuitem)

  menu2.AddItem(MenuItem("Back",
    RunCallback(lambda a,b: a.Replace(menu, direction=1))))
  for i in range(30):
    menu2.AddItem(MenuItem("george %d" % i, RunCallback(doit)))

  menu2.SetVisible(False)
  fixed.put(menu2.widget(), 100, 0)
  window.show_all()
  menu2.widget().hide()
  menu.widget().show()

  gtk.main()

